package com.xh.web.controller;

import java.util.List;

import com.xh.web.constant.AjaxResult;
import com.xh.web.domain.DTemplate;
import com.xh.web.service.IDTemplateService;
import com.xh.web.util.TableDataInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;


/**
 * 业务名Controller
 *
 * @author 宁兴海
 * @date 2021-12-10
 */
@RestController
@RequestMapping("/db/template")
public class DTemplateController extends BaseController
{
    @Autowired
    private IDTemplateService dTemplateService;

    /**
     * 查询业务名列表
     */
    @GetMapping("/list")
    public TableDataInfo list(DTemplate dTemplate)
    {
        //startPage();
        List<DTemplate> list = dTemplateService.selectDTemplateList(dTemplate);
        return getDataTable(list);
    }

    /**
     * 获取业务名详细信息
     */
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") String id)
    {
        return AjaxResult.success(dTemplateService.selectDTemplateById(id));
    }

    /**
     * 新增业务名
     */
    @PostMapping("/add")
    public AjaxResult add(@RequestBody DTemplate dTemplate)
    {
        return toAjax(dTemplateService.insertDTemplate(dTemplate));
    }

    /**
     * 修改业务名
     */
    @PutMapping
    public AjaxResult edit(@RequestBody DTemplate dTemplate)
    {
        return toAjax(dTemplateService.updateDTemplate(dTemplate));
    }

    /**
     * 删除业务名
     */
	@DeleteMapping("/remove/{ids}")
    public AjaxResult remove(@PathVariable String[] ids)
    {
        return toAjax(dTemplateService.deleteDTemplateByIds(ids));
    }
}
